//package com.itisyue.fun.service;
//
//import com.alibaba.fastjson.JSONObject;
//import com.alibaba.nacos.api.config.annotation.NacosValue;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.BeansException;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.ApplicationContext;
//import org.springframework.context.ApplicationContextAware;
//import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
//import org.springframework.stereotype.Service;
//
//import javax.annotation.PostConstruct;
//import javax.annotation.Resource;
//import java.util.Timer;
//import java.util.TimerTask;
//import java.util.concurrent.ThreadPoolExecutor;
//
//@Service
//public class InitServiceImpl implements ApplicationContextAware {
//    Logger log = LoggerFactory.getLogger(InitServiceImpl.class);
//
//    @NacosValue(value = "${nacos.test.properties:123}", autoRefreshed = true)
//    private String testProperties;
//
//    @Resource
//    private ThreadPoolExecutor taskExecutor;
//
//    private ApplicationContext applicationContext;
//
//    @Override
//    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
//        this.applicationContext  = applicationContext;
//    }
//
//    @PostConstruct
//    private void initTest(){
//        String[] activeProfile = applicationContext.getEnvironment().getActiveProfiles();
//        log.info("initTest profile={}", JSONObject.toJSONString(activeProfile));
//        log.info("===========开始初始化 doInit.start===========");
//        this.doInit();
//        this.startRefreshTimer();
//        log.info("===========开始初结束 doInit.end  ===========");
//
//    }
//    public void doInit(){
//        log.info("doInit ......");
//        for(int i=0;i<Math.random()*100+10;i++){
//            taskExecutor.execute(new ThreadRun(testProperties));
//        }
//    }
//    private void startRefreshTimer(){
//        new Timer().schedule(new TimerTask() {
//            @Override
//            public void run() {
//                InitServiceImpl.this.doInit();
//            }
//        }, (long) (30*1000), (long) (30*1000));
//    }
//}
